import React, { Component } from "react";
// NavLink具有Link的功能，并且可以做导航高亮
import { NavLink, Route, Switch } from "react-router-dom";

import "./08-style.css";

class Home extends Component {
  render() {
    return <div>首页</div>;
  }
}
class About extends Component {
  render() {
    return <div>关于页</div>;
  }
}
class Mine extends Component {
  render() {
    return <div>我的页</div>;
  }
}

class Basic extends Component {
  state = {};
  render() {
    return (
      <>
        <h3>路由导航高亮</h3>
        <ul>
          <li>
            <NavLink to="/" exact activeClassName="select">
              home
            </NavLink>
          </li>
          <li>
            <NavLink to="/about" activeClassName="select">
              about
            </NavLink>
          </li>
          <li>
            <NavLink to="/mine" activeClassName="select">
              mine
            </NavLink>
          </li>
        </ul>

        <Switch>
          <Route path="/" component={Home} exact></Route>
          <Route path="/about" component={About}></Route>
          <Route path="/mine" component={Mine}></Route>
        </Switch>
      </>
    );
  }
}

export default Basic;
